import Vue from 'vue'
import Router from 'vue-router'
import store from '../store/index'
import goods from '../components/goods/goods';
import ratings from '../components/ratings/ratings';
import seller from '../components/seller/seller';
import my from '../components/my/my.vue'
import add_adress from '../components/adress/add_adress.vue'
import adress_list from '../components/adress/adress_list.vue'
import order from '../components/order/order.vue'
import order_list from '../components/order/order_list.vue'
import login_page from '../components/login/login.vue'
import sub_success from '../components/order/order_success.vue'
import order_detail from '../components/order/order_details.vue'
Vue.use(Router)

const router = new Router({
  routes: [{
    path: '/',
    component: goods
  }, {
    path: '/goods',
    component: goods
  }, {
    path: '/login',
    component: login_page
  },
  {
    path: '/ratings',
    component: ratings
  }, {
    path: '/seller',
    component: seller
  }, {
    path: '/my',
    component: my
  },{
    path: '/add_adress',
    component: add_adress
  },{
    path: '/adress_list',
    component: adress_list
  },{
    path: '/order',
    component: order
  },{
    path: '/order_list',
    component: order_list
  },{
    path: '/order_success',
    component: sub_success
  },{
    path: '/order_detail',
    component: order_detail
  }
  
]
})
router.beforeEach((to, from, next) => {
  if (to.path == '/goods' || to.path == '/ratings' || to.path == '/seller' || to.path == '/') {
    store.state.main_tle_show = true
    next()
  } else {
    store.state.main_tle_show = false
    next()
  }

})
export default router
